using System;
using System.Web.UI;
using System.Web.UI.Adapters;
using System.Web.UI.HtmlControls;
using System.Collections;

namespace MyWebPagesStarterKit.Adapters
{
    public class HtmlMetaAdapter : ControlAdapter
    {
        protected override void Render(HtmlTextWriter writer)
        {
            /*
            HtmlMeta control = (HtmlMeta) base.Control;
            writer.Write("\t<meta name=\"");
            writer.Write(control.Name);
            writer.Write("\" content=\"");
            writer.Write(control.Content);
            writer.WriteLine("\" />");
            
             Changed to support meta http-equiv
             */

            HtmlMeta control = (HtmlMeta)base.Control;
            writer.Write("\t<meta");
            AttributeCollection attributes = control.Attributes;
            IEnumerator enumerator = control.Attributes.Keys.GetEnumerator();
            while (enumerator.MoveNext())
            {
                string current = (string)enumerator.Current;
                writer.Write(" ");
                writer.Write(current);
                writer.Write("=\"");
                writer.Write(attributes[current].Replace("~", ""));
                writer.Write("\"");
            }
            writer.WriteLine(" />");
        }
    }
}
